home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / dev / gui / DesignerV1_53.lha / Designer / KeyDemo / KeyDemo.s < prev    next >
Text File  |  1995-04-28  |  14KB  |  492 lines

  1. ; Compile me to get full executable
  2.  
  3.     include    keydemowin.i
  4.  
  5. GT_ReplyIMsg             EQU    -78
  6. GT_GetIMsg               EQU    -72
  7. WaitPort                 EQU    -384
  8. ItemAddress              EQU    -144
  9. GT_BeginRefresh          EQU    -90
  10. GT_EndRefresh            EQU    -96
  11. CloseScreen              EQU    -66
  12. GT_SetGadgetAttrs        EQU    -42
  13. ActivateGadget           EQU    -462
  14.  
  15. start
  16.  
  17.     jsr     OpenLibs                    ; Open libraries
  18.     tst.l   d0                          ; Test result
  19.     bne     NoLibs                      ; If cannot open the exit
  20.     jsr     OpenMainWindowWindow        ; Open window
  21.     tst.l   d0                          ; Test window
  22.     bne     NoWindow                    ; If window not open then fail
  23. WaitHere:
  24.     move.l  MainWindow,a1               ; Get win address
  25.     move.l  86(a1),a2                   ; Get message port
  26.     move.l  a2,a0
  27.     move.l  _SysBase,a6                 ; Prepare for system call
  28.     jsr     WaitPort(a6)                ; Wait for message at port
  29. GetMessage:
  30.     move.l  MainWindow,a1               ; Get win address
  31.     move.l  86(a1),a2                   ; Get message port
  32.     move.l  a2,a0
  33.     move.l  _GadToolsBase,a6            ; Prepare for GadTools call
  34.     jsr     GT_GetIMsg(a6)              ; Get message
  35.     tst.l   d0                          ; See if message arrived
  36.     beq     WaitHere                    ; If no message then wait for next
  37.     move.l  d0,a1                       ; Put intuimessage in a1
  38.     move.l  20(a1),d2                   ; Get class
  39.     move.w  24(a1),d3                   ; Get code
  40.     move.l  28(a1),a4                   ; Get IAddress
  41.     move.l  20(a1),d4                   ; Get class in d4
  42.     
  43.     move.l  _GadToolsBase,a6            ; Prepare for GadTools call
  44.     jsr     GT_ReplyIMsg(a6)            ; Reply message
  45.  
  46.     cmpi.l  #$200,d4                    ; Quit if window closed
  47.     beq     Done                        ; Remove when proper method implemented
  48.     move.l  d2,d0                       ; Get class
  49.     move.w  d3,d1                       ; Get code
  50.     move.l  a4,a0                       ; Get IAddress
  51.     jmp     ProcessWindowMainWindow     ; Call process routine
  52. MainWindowDoneMessage:
  53.     
  54.     jmp     GetMessage                  ; Get next message
  55. Done:
  56.     move.l  MainWindow,d0               ; Put window in d0
  57.     tst.l   d0                          ; See if window open
  58.     beq     NoWindow                    ; If it is not open then skip close
  59.     jsr     CloseMainWindowWindow       ; Close Window
  60. NoWindow:                               ; Window cannot be opened
  61.     jsr     CloseLibs                   ; Close libraries
  62. NoLibs:                                 ; Could not open libraries
  63.     rts                                 ; Return
  64.  
  65.  
  66.                                         ; Cut the core out of this function and edit it suitably.
  67.  
  68. ProcessWindowMainWindow:                ; Class in d0,code in d1,iaddress in a0 required, others are up to you.
  69.     cmp.l   #$20,d0                     ; IDCMP_GADGETDOWN
  70.     bne     NotGADGETDOWN
  71.                                         ;  Gadget message, gadget is in a0
  72.     move.w  38(a0),d0                   ; Get id in d0
  73.     cmp.w   #GD_StringGadget,d0
  74.     bne     NotStringGadgetDown
  75.                                         ; String entered   , Text of gadget : _String
  76.     jmp     MainWindowDoneMessage
  77. NotStringGadgetDown:
  78.     cmp.w   #GD_IntegerGadget,d0
  79.     bne     NotIntegerGadgetDown
  80.                                         ; Integer entered  , Text of gadget : _Integer
  81.     jmp     MainWindowDoneMessage
  82. NotIntegerGadgetDown:
  83.     cmp.w   #GD_MXGadget,d0
  84.     bne     NotMXGadgetDown
  85.                                         ; MX changed       , Text of gadget : 
  86.     jmp     MainWindowDoneMessage
  87. NotMXGadgetDown:
  88.     cmp.w   #GD_SliderGadget,d0
  89.     bne     NotSliderGadgetDown
  90.                                         ; Slider changed   , Text of gadget : S_lider
  91.     move.l  #0,d0
  92.     move.w  d1,d0
  93.     move.l  d0,sliderpos
  94.     jmp     MainWindowDoneMessage
  95. NotSliderGadgetDown:
  96.     cmp.w   #GD_ScrollerGadget,d0
  97.     bne     NotScrollerGadgetDown
  98.                                         ; Scroller changed , Text of gadget : Scrolle_r
  99.     move.l  #0,d0
  100.     move.w  d1,d0
  101.     move.l  d0,scrollerpos
  102.     jmp     MainWindowDoneMessage
  103. NotScrollerGadgetDown:
  104.     jmp     MainWindowDoneMessage
  105. NotGADGETDOWN:
  106.     cmp.l   #$40,d0                     ; IDCMP_GADGETUP
  107.     bne     NotGADGETUP
  108.                                         ;  Gadget message, gadget is in a0
  109.     move.w  38(a0),d0                   ; Get id in d0
  110.     cmp.w   #GD_CheckBoxGadget,d0
  111.     bne     NotCheckBoxGadgetUp
  112.                                         ; CheckBox changed, Text of gadget : _CheckBox
  113.     jmp     MainWindowDoneMessage
  114. NotCheckBoxGadgetUp:
  115.     cmp.w   #GD_CycleGadget,d0
  116.     bne     NotCycleGadgetUp
  117.                                         ; Cycle changed   , Text of gadget : C_ycle
  118.     move.l  #0,d0
  119.     move.w  d1,d0
  120.     move.l  d0,cyclepos
  121.     jmp     MainWindowDoneMessage
  122. NotCycleGadgetUp:
  123.     cmp.w   #GD_SliderGadget,d0
  124.     bne     NotSliderGadgetUp
  125.                                         ; Slider changed  , Text of gadget : S_lider
  126.     move.l  #0,d0
  127.     move.w  d1,d0
  128.     move.l  d0,sliderpos
  129.     jmp     MainWindowDoneMessage
  130. NotSliderGadgetUp:
  131.     cmp.w   #GD_ScrollerGadget,d0
  132.     bne     NotScrollerGadgetUp
  133.                                         ; Scroller changed, Text of gadget : Scrolle_r
  134.     move.l  #0,d0
  135.     move.w  d1,d0
  136.     move.l  d0,scrollerpos
  137.     jmp     MainWindowDoneMessage
  138. NotScrollerGadgetUp:
  139.     cmp.w   #GD_PaletteGadget,d0
  140.     bne     NotPaletteGadgetUp
  141.                                         ; Colour Selected , Text of gadget : _Palette
  142.     move.l  #0,d0
  143.     move.w  d1,d0
  144.     move.l  d0,palettepos
  145.     jmp     MainWindowDoneMessage
  146. NotPaletteGadgetUp:
  147.     jmp     MainWindowDoneMessage
  148. NotGADGETUP:
  149.     cmp.l   #4,d0                       ; IDCMP_REFRESHWINDOW
  150.     bne     NotREFRESHWINDOW
  151.     movea.l MainWindow,a0
  152.     movea.l _GadToolsBase,a6
  153.     jsr     GT_BeginRefresh(a6)
  154.     move.l  #1,d0
  155.     movea.l MainWindow,a0
  156.     jsr     GT_EndRefresh(a6)
  157.     jmp     MainWindowDoneMessage
  158. NotREFRESHWINDOW:
  159.     cmp.l   #$200000,d0                 ; IDCMP_VANILLAKEY
  160.     bne     NotVANILLAKEY
  161.                                         ; Processed key press
  162.     cmp.w   #'q',d1
  163.     beq     Done
  164.     
  165.     cmp.w   #'Q',d1
  166.     beq     Done
  167.     
  168.     cmp.w   #'b',d1
  169.     beq     ButtonPressed
  170.     
  171.     cmp.w   #'B',d1
  172.     beq     ButtonPressed
  173.     
  174.     cmp.w   #'l',d1
  175.     beq     SliderUp
  176.     
  177.     cmp.w   #'L',d1
  178.     beq     SliderDown
  179.     
  180.     cmp.w   #'r',d1
  181.     beq     ScrollerUp
  182.     
  183.     cmp.w   #'R',d1
  184.     beq     ScrollerDown
  185.     
  186.     cmp.w   #'p',d1
  187.     beq     PaletteDown
  188.     
  189.     cmp.w   #'P',d1
  190.     beq     PaletteUp
  191.     
  192.     cmp.w   #'y',d1
  193.     beq     CycleUp
  194.     
  195.     cmp.w   #'Y',d1
  196.     beq     CycleDown
  197.     
  198.     cmp.w   #'c',d1
  199.     beq     ToggleCheckBox
  200.     
  201.     cmp.w   #'C',d1
  202.     beq     ToggleCheckBox
  203.     
  204.     cmp.w   #'0',d1
  205.     beq     MX0
  206.     
  207.     cmp.w   #'1',d1
  208.     beq     MX1
  209.     
  210.     cmp.w   #'2',d1
  211.     beq     MX2
  212.     
  213.     cmp.w   #'3',d1
  214.     beq     MX3
  215.     
  216.     cmp.w   #'s',d1
  217.     beq     StringActive
  218.     
  219.     cmp.w   #'S',d1
  220.     beq     StringActive
  221.     
  222.     cmp.w   #'i',d1
  223.     beq     IntegerActive
  224.     
  225.     cmp.w   #'I',d1
  226.     beq     IntegerActive
  227.     
  228. NotVANILLAKEY:
  229.     jmp     MainWindowDoneMessage
  230.  
  231. ButtonPressed:
  232.     jmp     MainWindowDoneMessage
  233.  
  234. SliderUp:
  235.     move.l  sliderpos,d0
  236.     cmpi.l  #15,d0
  237.     beq     SkipSliderInc
  238.     add.l   #1,sliderpos
  239. SkipSliderInc:
  240.     move.l  #GD_SliderGadget,d0
  241.     mulu    #4,d0
  242.     lea.l   MainWindowGadgets,a0
  243.     adda.l  d0,a0
  244.     movea.l (a0),a0                  ; Gadget in a0
  245.     movea.l MainWindow,a1
  246.     movea.l #0,a2
  247.     lea     tags,a3
  248.     movea.l _GadToolsBase,a6
  249.     move.l  sliderpos,ti_data
  250.     move.l  #$80080028,ti_tag       ; GTSL_Level
  251.     jsr     GT_SetGadgetAttrs(a6)
  252.     jmp     MainWindowDoneMessage
  253.  
  254. SliderDown:
  255.     move.l  sliderpos,d0
  256.     cmpi.l  #0,d0
  257.     beq     SkipSliderDec
  258.     sub.l   #1,sliderpos
  259. SkipSliderDec:
  260.     move.l  #GD_SliderGadget,d0
  261.     mulu    #4,d0
  262.     lea.l   MainWindowGadgets,a0
  263.     adda.l  d0,a0
  264.     movea.l (a0),a0                  ; Gadget in a0
  265.     movea.l MainWindow,a1
  266.     movea.l #0,a2
  267.     lea     tags,a3
  268.     movea.l _GadToolsBase,a6
  269.     move.l  sliderpos,ti_data
  270.     move.l  #$80080028,ti_tag       ; GTSL_Level
  271.     jsr     GT_SetGadgetAttrs(a6)
  272.     jmp     MainWindowDoneMessage
  273.  
  274. ScrollerUp:
  275.     move.l  scrollerpos,d0
  276.     cmpi.l  #8,d0
  277.     beq     SkipScrollerInc
  278.     add.l   #1,scrollerpos
  279. SkipScrollerInc:
  280.     move.l  #GD_ScrollerGadget,d0
  281.     mulu    #4,d0
  282.     lea.l   MainWindowGadgets,a0
  283.     adda.l  d0,a0
  284.     movea.l (a0),a0                  ; Gadget in a0
  285.     movea.l MainWindow,a1
  286.     movea.l #0,a2
  287.     lea     tags,a3
  288.     movea.l _GadToolsBase,a6
  289.     move.l  scrollerpos,ti_data
  290.     move.l  #$80080015,ti_tag       ; GTSC_Top
  291.     jsr     GT_SetGadgetAttrs(a6)
  292.     jmp     MainWindowDoneMessage
  293.  
  294. ScrollerDown:
  295.     move.l  scrollerpos,d0
  296.     cmpi.l  #0,d0
  297.     beq     SkipScrollerDec
  298.     sub.l   #1,scrollerpos
  299. SkipScrollerDec:
  300.     move.l  #GD_ScrollerGadget,d0
  301.     mulu    #4,d0
  302.     lea.l   MainWindowGadgets,a0
  303.     adda.l  d0,a0
  304.     movea.l (a0),a0                  ; Gadget in a0
  305.     movea.l MainWindow,a1
  306.     movea.l #0,a2
  307.     lea     tags,a3
  308.     movea.l _GadToolsBase,a6
  309.     move.l  scrollerpos,ti_data
  310.     move.l  #$80080015,ti_tag        ; GTSC_Top
  311.     jsr     GT_SetGadgetAttrs(a6)
  312.     jmp     MainWindowDoneMessage
  313.  
  314. PaletteUp:
  315.     move.l  MainWindowDepth,d1
  316.     move.l  #1,d2
  317.     asl.l   d1,d2
  318.     move.l  palettepos,d0
  319.     cmpi.l  #0,d0
  320.     bne     SkipPaletteDown
  321.     move.l  d2,palettepos
  322. SkipPaletteDown:
  323.     sub.l   #1,palettepos
  324.     move.l  #GD_PaletteGadget,d0
  325.     mulu    #4,d0
  326.     lea.l   MainWindowGadgets,a0
  327.     adda.l  d0,a0
  328.     movea.l (a0),a0                  ; Gadget in a0
  329.     movea.l MainWindow,a1
  330.     movea.l #0,a2
  331.     lea     tags,a3
  332.     movea.l _GadToolsBase,a6
  333.     move.l  palettepos,ti_data
  334.     move.l  #$80080011,ti_tag        ; GTPA_Color
  335.     jsr     GT_SetGadgetAttrs(a6)
  336.     jmp     MainWindowDoneMessage
  337.  
  338. PaletteDown:
  339.     move.l  MainWindowDepth,d1
  340.     move.l  #1,d2
  341.     asl.l   d1,d2
  342.     add.l   #1,palettepos
  343.     move.l  palettepos,d0
  344.     cmp.l   d2,d0
  345.     bne     SkipPaletteUp
  346.     move.l  #0,palettepos
  347. SkipPaletteUp:
  348.     move.l  #GD_PaletteGadget,d0
  349.     mulu    #4,d0
  350.     lea.l   MainWindowGadgets,a0
  351.     adda.l  d0,a0
  352.     movea.l (a0),a0                  ; Gadget in a0
  353.     movea.l MainWindow,a1
  354.     movea.l #0,a2
  355.     lea     tags,a3
  356.     movea.l _GadToolsBase,a6
  357.     move.l  palettepos,ti_data
  358.     move.l  #$80080011,ti_tag        ; GTPA_Color
  359.     jsr     GT_SetGadgetAttrs(a6)
  360.     jmp     MainWindowDoneMessage
  361.  
  362. CycleUp:
  363.     add.l   #1,cyclepos
  364.     move.l  cyclepos,d0
  365.     cmpi.l  #4,d0
  366.     bne     SkipCycleDown
  367.     move.l  #0,cyclepos
  368. SkipCycleDown:
  369.     move.l  #GD_CycleGadget,d0
  370.     mulu    #4,d0
  371.     lea.l   MainWindowGadgets,a0
  372.     adda.l  d0,a0
  373.     movea.l (a0),a0                  ; Gadget in a0
  374.     movea.l MainWindow,a1
  375.     movea.l #0,a2
  376.     lea     tags,a3
  377.     movea.l _GadToolsBase,a6
  378.     move.l  cyclepos,ti_data
  379.     move.l  #$8008000F,ti_tag        ; GTCY_Active
  380.     jsr     GT_SetGadgetAttrs(a6)
  381.     jmp     MainWindowDoneMessage
  382.  
  383. CycleDown:
  384.     move.l  cyclepos,d0
  385.     cmpi.l  #0,d0
  386.     bne     SkipCycleUp
  387.     move.l  #4,cyclepos
  388. SkipCycleUp:
  389.     sub.l   #1,cyclepos
  390.     move.l  #GD_CycleGadget,d0
  391.     mulu    #4,d0
  392.     lea.l   MainWindowGadgets,a0
  393.     adda.l  d0,a0
  394.     movea.l (a0),a0                  ; Gadget in a0
  395.     movea.l MainWindow,a1
  396.     movea.l #0,a2
  397.     lea     tags,a3
  398.     movea.l _GadToolsBase,a6
  399.     move.l  cyclepos,ti_data
  400.     move.l  #$8008000F,ti_tag        ; GTCY_Active
  401.     jsr     GT_SetGadgetAttrs(a6)
  402.     jmp     MainWindowDoneMessage
  403.  
  404. StringActive:
  405.     move.l  #GD_StringGadget,d0
  406.     mulu    #4,d0
  407.     lea.l   MainWindowGadgets,a0
  408.     adda.l  d0,a0
  409.     movea.l (a0),a0                  ; Gadget in a0
  410.     movea.l MainWindow,a1
  411.     movea.l #0,a2
  412.     movea.l _IntuitionBase,a6
  413.     jsr     ActivateGadget(a6)
  414.     jmp     MainWindowDoneMessage
  415.  
  416. IntegerActive:
  417.     move.l  #GD_IntegerGadget,d0
  418.     mulu    #4,d0
  419.     lea.l   MainWindowGadgets,a0
  420.     adda.l  d0,a0
  421.     movea.l (a0),a0                  ; Gadget in a0
  422.     movea.l MainWindow,a1
  423.     movea.l #0,a2
  424.     movea.l _IntuitionBase,a6
  425.     jsr     ActivateGadget(a6)
  426.     jmp     MainWindowDoneMessage
  427.  
  428. MX0:
  429.     move.l  #0,ti_data
  430.     jmp     MXA
  431.  
  432. MX1:
  433.     move.l  #1,ti_data
  434.     jmp     MXA
  435.  
  436. MX2:
  437.     move.l  #2,ti_data
  438.     jmp     MXA
  439.  
  440. MX3:
  441.     move.l  #3,ti_data
  442.     jmp     MXA
  443.  
  444. MXA:
  445.     move.l  #GD_MXGadget,d0
  446.     mulu    #4,d0
  447.     lea.l   MainWindowGadgets,a0
  448.     adda.l  d0,a0
  449.     movea.l (a0),a0                  ; Gadget in a0
  450.     movea.l MainWindow,a1
  451.     movea.l #0,a2
  452.     lea     tags,a3
  453.     movea.l _GadToolsBase,a6
  454.     move.l  #$8008000A,ti_tag       ; GTMX_Active
  455.     jsr     GT_SetGadgetAttrs(a6)
  456.     jmp     MainWindowDoneMessage
  457.  
  458. ToggleCheckBox:
  459.     move.l  #GD_CheckBoxGadget,d0
  460.     mulu    #4,d0
  461.     lea.l   MainWindowGadgets,a0
  462.     adda.l  d0,a0
  463.     movea.l (a0),a0                  ; Gadget in a0
  464.     movea.l MainWindow,a1
  465.     movea.l #0,a2
  466.     lea     tags,a3
  467.     movea.l _GadToolsBase,a6
  468.     move.l  #$80080004,ti_tag        ; GTCB_Checked 
  469.     move.w  12(a0),d0
  470.     move.l  #1,ti_data
  471.     btst    #7,d0
  472.     beq     CorrectTag
  473.     move.l  #0,ti_data
  474. CorrectTag:
  475.     jsr     GT_SetGadgetAttrs(a6)
  476.     jmp     MainWindowDoneMessage
  477.  
  478. tags:
  479. ti_tag:
  480.     dc.l    0
  481. ti_data:
  482.     dc.l    0,0
  483. sliderpos:
  484.     dc.l    0
  485. scrollerpos:
  486.     dc.l    0
  487. cyclepos:
  488.     dc.l    0
  489. palettepos  
  490.     dc.l    0
  491.     end
  492.